let index = 1000
export function getEchartId() {
    return index++
}

let scriptPromise = null

export function loadEcharts() {
    if (scriptPromise) {
        return scriptPromise
    }
    scriptPromise = new Promise((resolve) => {
        let el = document.createElement('script')
        el.src = 'https://oss.petslib.cn/prod/static/cdns/echarts/4.9.0/echarts.min.js'
        el.onload = resolve
        let s = document.getElementsByTagName('script')[0]
        s.parentNode.insertBefore(el, s)
    })
    return scriptPromise
}